package comWorld.action.blog;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import comWorld.blog.BlogInfoManage;
import comWorld.favorite.FavoriteManage;
import comWorld.user.UserInfo;

/**
 * Servlet implementation class DeleteFavor
 */
@WebServlet("/action/blog/deleteFavor")
public class DeleteFavor extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DeleteFavor() {
        super();
    }

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("application/json;charset=utf-8");
		int blogId = Integer.valueOf(request.getParameter("blogId"));
		UserInfo visitorInfo = (UserInfo) request.getSession().getAttribute("visitorInfo");
		FavoriteManage.deleteBlogFavor(blogId, visitorInfo.getId());
		PrintWriter out = response.getWriter();
		out.println("{\"status\":1}");
		out.close();
	}

}
